package fun.easycode.webterminal.common.config;

import fun.easycode.webterminal.common.datafill.DataFillActuator;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Pointcut;
import org.springframework.stereotype.Component;

@Slf4j
@Component
@Aspect
public class DataFillAop {

    @Resource
    private DataFillActuator dataFillActuator;

    @Pointcut("@annotation(fun.easycode.webterminal.common.datafill.DataFill)")
    public void pointCut(){
    }

    @Around(("pointCut()"))
    public Object perform(ProceedingJoinPoint joinPoint) throws Throwable {
        Object result = joinPoint.proceed();
        dataFillActuator.execute(result);
        return result;
    }
}
